package com.ecmcloud.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ecmcloud.common.dto.Result;
import com.ecmcloud.entity.Process;
import com.ecmcloud.service.IProcessService;
import com.ecmcloud.vo.ProcessVO;

@RestController
@RequestMapping(value = {"process", "api/process"})
public class ProcessResource {

	@Autowired
    private IProcessService processService;

    /**
     * 获取详细数据
     *
     * @param flowId
     * @return
     */
    @GetMapping("getDetail")
    public Result<ProcessVO> getDetail(String flowId) {
        return processService.getDetail(flowId);
    }

    /**
     * 创建流程
     *
     * @param process
     * @return
     */
    @PostMapping("create")
    public Result<String> create(@RequestBody Process process) {
        return processService.create(process);
    }

    /**
     * 编辑表单
     *
     * @param flowId 摸板ID
     * @param type       类型 stop using delete
     * @return 操作结果
     */
    @PutMapping("update/{flowId}")
   public Result<String> update(@PathVariable String flowId,@RequestParam String type,@RequestParam(required = false) Long groupId){
        return processService.update(flowId, type, groupId);
    }
    
}
